<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="com.ereport.entity.AccContacts"%>
<%@page import="java.util.List"%>
<%@page import="java.text.DateFormat"%>
<%@page import="com.ereport.entity.Accounts"%>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="<%=application.getContextPath() %>/css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=application.getContextPath() %>/js/jquery-1.6.min.js"></script>	
<script language="javascript" src="<%=application.getContextPath() %>/js/calendar_eu.js"></script>
<script type="text/javascript" src="<%=application.getContextPath() %>/js/jquery-ui-1.8.17.custom.min.js"></script>	
<link rel="stylesheet" href="<%=application.getContextPath() %>/css/jquery-ui-1.8.17.custom.css"/>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.js"></script>	
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.min.js"></script>
<!-- <script>
	$(document).ready(function(){
	$('#org').live('focusin',function(){
	var orlist=$("#orglist").val();
	var temp=orlist.split("/");
	//alert(temp);
		$('#org').autocomplete({
			source: temp
		});
		jQuery('.ui-autocomplete').css({'font-size':'10px','font-family':'Arial','max-height': '100px',
	'overflow-y': 'auto', 'padding-right': '20px', 'overflow-x': 'hidden'});
	
	});
	});
	
	</script> -->
<script>
  $(document).ready(function(){
    $("#myform").validate({
  messages: {
	  exeName:
      {
          required: "Executive Name must not be empty.",
      },
      org:
      {
          required: "Organisation must not be empty.",
          
      },
      accCreatedDate:
      {
          required: "Account Created Date must not be empty.",
      }
      
   
  }
});
  });
  </script>
 <style>
  	#field, label { float: left; font-family: Arial, Helvetica, sans-serif; font-size: 11px; }
  	label {  width: 14em; }
	br { clear: both; }
	input.error { border: 1px solid red;  }
	select.error{ border: 1px solid red;  }
	label.error {
		padding-left: 16px;
		margin-left: .3em;
		color: red;
		
	}
	.textfield{
		height: 22px;
		width: 180px; 
	}
	.textarea1{
		height: 52px;
		width: 180px;
	}
	.button-black{
		height: 23px;
		width: 23px;
		font-size: 11px;
		padding-top:3px;
		
	}
	.button-black:hover{
		height: 23px;
		width: 23px;
		font-size: 11px;
		padding-top:3px;
		
	}
	.form{
		width: 223px;
	}
</style>

<script language="javascript">
	var newRowCount=1;
        function addRow(infotable) {
 
            var table = document.getElementById(infotable);
 			var rowCount = table.rows.length;
			var row = table.insertRow(rowCount);
			row.className="tdinput";
			
		    var cell1 = row.insertCell(0);
		    cell1.setAttribute("bgcolor","#cccccc");
            var element1 = document.createElement("input");
            element1.type = "checkbox";
            cell1.appendChild(element1);
 			
			
            var cell2 = row.insertCell(1);
            cell2.setAttribute("bgcolor","#cccccc");
            cell2.setAttribute("align","center");
            cell2.innerHTML = rowCount;
 
          			
			 var cell3 = row.insertCell(2);
            cell3.setAttribute("bgcolor","#cccccc");
            cell3.innerHTML='<input name="contName'+(newRowCount+1)+'" class="tdinput" id="contName'+(newRowCount+1)+'" type="text" size="8"   />';
			
			
			var cell4 = row.insertCell(3);
			cell4.setAttribute("bgcolor","#cccccc");
			cell4.innerHTML='<input name="contPin'+(newRowCount+1)+'" id="contPin'+(newRowCount+1)+'" type="text" size="8" class="tdinput"/>';
			
			var cell5 = row.insertCell(4);
			cell5.setAttribute("bgcolor","#cccccc");
			cell5.innerHTML='<input name="contEmail'+(newRowCount+1)+'" id="contEmail'+(newRowCount+1)+'" type="text" size="8" class="tdinput"/>';
			
			var cell6 = row.insertCell(5);
			cell6.setAttribute("bgcolor","#cccccc");
			cell6.setAttribute("align","center");
			cell6.innerHTML='<input name="contPhone'+(newRowCount+1)+'" id="contPhone'+(newRowCount+1)+'" type="text" size="8" class="tdinput"/>';
            
		    var cell7 = row.insertCell(6);
		    cell7.setAttribute("bgcolor","#cccccc");
		    cell7.innerHTML='<input name="contJobRole'+(newRowCount+1)+'" id="contJobRole'+(newRowCount+1)+'" type="text" size="8" class="tdinput"/>';
           			
			var cell8 = row.insertCell(7);
            cell8.setAttribute("bgcolor","#cccccc");
            cell8.innerHTML='<input name="lstCont'+(newRowCount+1)+'" id="lstCont'+(newRowCount+1)+'" type="text" size="8" class="tdinput"/>';
			
			newRowCount++;
			        $("#rCount").val(newRowCount);
 			
			        $( "#lstCont"+newRowCount ).datepicker({ dateFormat: "dd-mm-yy" });
        }
 
        function deleteRow(infotable) {
            try {
            var table = document.getElementById(infotable);
            var rowCount = table.rows.length;
 
            for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                }
 
            }
			for(var i=0; i<rowCount-1; i++){
				
			var r=table.rows[i+1];
           r.cells[1].innerHTML = i+1;
                   
          
			}
			 
            }catch(e) {
                alert(e);
            }
        }
 
    </script>
    <script>

	$(function() {
		$( "#accCreatedDate" ).datepicker({ dateFormat: "dd-mm-yy" });
	});
	</script>
    <script>

	$(function() {
		$( "#lstCont1" ).datepicker({ dateFormat: "dd-mm-yy" });
	});
	</script>
	
</head>
 
<body>
<form action="<%=application.getContextPath() %>/accountsInAdmin/save.do" method="post" name="myform" id="myform"><table width="927" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td height="116" align="left" valign="top" background="<%=application.getContextPath() %>/images/top-bg.jpg" style="background-repeat:repeat-x; background-position:left top">
    <%@ include file="../common/exe-header.jsp" %>
    </td>
  </tr>
  <tr>
    <td height="600" align="left" valign="top"><table width="927" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="20">&nbsp;</td>
        <td width="643" align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="left" valign="top">&nbsp;<a href="<%=application.getContextPath() %>/user/open.do"><img src="<%=application.getContextPath() %>/images/home1.jpg" width="20" height="20" border="0" /></a></td>
              <td width="8%" align="center"><a href="<%=application.getContextPath() %>/user/logout.do" style="font-family: sans-serif;">&nbsp;&nbsp;Logout</a></td>
            </tr>
          </table>
        </td>
        <td width="20">&nbsp;</td>
      </tr>
      <tr>
        <td width="20">&nbsp;</td>
        <td align="center" valign="top" class="heading">Account Details</td>
        <td width="20">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td align="right"></td>
        <td>&nbsp;</td>
      </tr>
      <%
      
      %>
      <tr>
        <td>&nbsp;</td>
        <td align="center" valign="top"><table width="870" border="0" cellspacing="0" cellpadding="0">
       <tr>
            <td align="left" valign="top">
           <table width="895" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td><%
                Accounts acc=(Accounts)request.getAttribute("acc");
                List<AccContacts> aclist=(List<AccContacts>)request.getAttribute("acContList");
                
                %>
                <table width="100%" border="0" cellpadding="0" cellspacing="0" class="box-border1">
                  <tr>
                    <td width="366"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="29">&nbsp;</td>
                          <td width="168">&nbsp;</td>
                          <td width="250">&nbsp;</td>
                          <td width="23">&nbsp;</td>
                        </tr>
                        <tr>
                          <td width="29">&nbsp;</td>
                          <td align="left" valign="top" class="content">Executive Name</td>
                          <td width="250" align="left" class="hed-blc">
      						<select name="exeName" id="exeName" class="textfield required" tabindex="1" >
                 				 <option value="">Please Select</option>
                 	 				<%
                 	 				
                 	 					List<Executives> exlist=(List<Executives>)request.getAttribute("exlist");
                 	 				System.out.println("exename2 "+exlist.size());
                 						 for(int i=0;i<exlist.size();i++){
                 		 				String exeName="";
                 		
                						exeName=(String)request.getAttribute("exeName");
                						System.out.println("exename "+exeName);
                						if(exlist.get(i).getExeName().equals(exeName)){
                					%>
                				<option value="<%= exlist.get(i).getId()%>" selected="selected"><%= exlist.get(i).getExeName()%></option>
                					<%
                						}else {
                		              	 
                 	 				%>
                 	 			<option value="<%= exlist.get(i).getId()%>"><%= exlist.get(i).getExeName()%></option>
                 					 <%
                 	 					} 
                 	 					}
                 	 				%>
                 				</select>                		   </td>
                          <td width="23">&nbsp;</td>
                        </tr>
                        <tr>
                          <td width="30">&nbsp;</td>
                          <td width="171">&nbsp;</td>
                          <td width="246">&nbsp;</td>
                          <td width="23">&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="28">&nbsp;</td>
                          <td align="left" valign="top" class="content">Account Name</td>
                          <td align="left" valign="top">
                          <table width="100%" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                          	<td width="83%" align="left" valign="top"> <input type="hidden" id="orglist" value="<%=request.getAttribute("acList")%>"/>
                         
                          <input type="text" name="org" id="org" class="textfield required"  value="<%=acc.getAccName() %>" /></td>
                            <td width="17%" align="left" valign="top">
                            <!-- <input type="button" id="go" class="button-black" value="GO"/> -->
                            </td>
                          </tr>
                          </table>
                         
                          </td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" valign="top" height="28" class="content">Account Number</td>
                          <td align="left" valign="top">
                          <input type="text" name="acNum" id="acNum" class="textfield" value="<%= acc.getAccNumber()%>"/></td>
                          <td align="left" valign="top">&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" valign="top" height="28" class="content">Industry Type </td>
                          <td align="left" valign="top">
                          <input name="indsType" id="indsType" type="text" class="textfield" value="<%=acc.getIndustryType() %>" /></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" valign="top" height="28" class="content">Primary Account Owner Name </td>
                          <td align="left" valign="top">
                          <input name="prAccOwnName" type="text" id="prAccOwnName" class="textfield" value="<%=acc.getPrimaryAccOwnrName() %>"/></td>
                          <td align="left" valign="top">&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" valign="top" height="28" class="content">Phone </td>
                          <td align="left" valign="top">
                          <input name="phn" type="text" id="phn" class="textfield" value="<%=acc.getPhone() %>"  /></td>
                          <td align="left" valign="top">&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                       
                        <tr>
                          <td height="28">&nbsp;</td>
                          <td class="content">Fax </td>
                          <td align="left" valign="top">
                          <input name="fax" type="text" id="fax" class="textfield" value="<%=acc.getFax() %>"/></td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                         <td height="5"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td height="28">&nbsp;</td>
                          <td class="content">Email </td>
                          <td align="left" valign="top">
                          <input name="email" type="text" id="email" class="textfield email" value="<%=acc.getEmail() %>" /></td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td>&nbsp;</td>
                          <td>&nbsp;</td>
                          <td>&nbsp;</td>
                        </tr>
                    </table></td>
                    <td width="330" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="66" height="21">&nbsp;</td>
                          <td width="220">&nbsp;</td>
                          <td width="261">&nbsp;</td>
                        </tr>
                        <tr>
                          <td >&nbsp;</td>
                          <td align="left" height="28" valign="top" class="content">Website</td>
                          <td align="left" valign="top">
                          <input type="text" name="website" id="website" class="textfield" value="<%=acc.getWebsite()%>" /></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" height="28" valign="top" class="content">Shipping Address </td>
                          <td align="left" valign="top">
                          <textarea name="shpAddr" id="shpAddr" class="textarea1"><%=acc.getShippingAddress() %></textarea></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" valign="top" class="content">Invoice Address</td>
                          <td align="left" valign="top">
                          <textarea name="invAddr" id="invAddr" class="textarea1" ><%=acc.getInvoiceAddr() %></textarea></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                        </tr>
                         <%
                          String ddate="";
                         Date dat=acc.getAccCreatedDate();
                          DateFormat dfmt=new SimpleDateFormat("dd-MM-yyyy");
                          	ddate=dfmt.format(dat.getTime());
                          %>
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" height="28" valign="top" class="content">Tax Register Number </td>
                          <td align="left" valign="top">
                          <input type="text" name="taxRegdNum" id="taxRegdNum" class="textfield" value="<%=acc.getTaxRegrNumber()%>"/></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                        </tr>
                       
                        <tr>
                          <td>&nbsp;</td>
                          <td class="content" height="28">Account Created Date </td>
                          <td><input name="accCreatedDate" id="accCreatedDate" type="text" class="textfield required" value="<%=ddate %>"  /></td>                        </tr>
                        
                        <tr>
                          <td>&nbsp;</td>
                          <td class="content">&nbsp;</td>
                          <td>&nbsp;</td>
                        </tr>
                    </table></td>
                  </tr>
                </table>
                
                </td>
              </tr>
              <tr>
                <td height="10" align="left" valign="top"></td>
              </tr>
              
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
              <td>
              <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td><table width="100%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#787878" style="border-top-left-radius: 5px;border-top-right-radius: 5px"  class="tablebox" id="iTable" >
                  <tr style="background:url('<%=application.getContextPath() %>/images/hed-bg-block-2.jpg'); background-repeat:repeat-x; background-position:left top">
                   	<td width="2%" align="center" valign="middle" class="hed" style="background-repeat:repeat-x;border-top-left-radius:5px "></td>
                    <td width="5%"  height="30" align="center" valign="middle"  class="hed"  style="background-repeat:repeat-x">S.No</td>
                    <td width="19%"  align="center" valign="middle"  class="hed"   style="background-repeat:repeat-x"> Contact Name </td>
                    <td width="10%"  align="center" valign="middle"  class="hed"   style="background-repeat:repeat-x">Pin</td>
                    <td width="19%"  align="center" valign="middle"  class="hed"   style="background-repeat:repeat-x">Email</td>
                    <td width="14%"  align="center" valign="middle"  class="hed"   style="background-repeat:repeat-x">Phone</td>
                    <td width="20%"  align="center" valign="middle"  class="hed"   style="background-repeat:repeat-x">Job Role</td>
                    <td width="13%"  align="center" valign="middle"  class="hed"   style="background-repeat:repeat-x">Last Contacted</td>
                   
                  </tr>
                  
                  <%
                  if(aclist!=null){
                  	for(int i=0;i<aclist.size();i++){
                   	System.out.println("aclist "+aclist.get(i).getContactName());
                  %>
                  <tr >
                   <%
                          String lcdate="";
                         Date ldt=aclist.get(i).getLastContact();
                          DateFormat ldft=new SimpleDateFormat("dd-MM-yyyy");
                          	lcdate=ldft.format(ldt.getTime());
                          	
                                              
                   %>
                   	<td  bgcolor="#cccccc" align="center" ><input type="checkbox" name="checkbox" value="checkbox" /></td>
                    <td bgcolor="#cccccc" align="center"><%=i+1 %></td>
                    <td align="left" valign="top" bgcolor="#cccccc">
                    <input name="contName1" id="contName1"  type="text" value="<%=aclist.get(i).getContactName() %>" size="5"  class="tdinput" /></td>
		            <td align="left" valign="top" bgcolor="#cccccc">
                    <input name="contPin1" id="contPin1" type="text" value="<%=aclist.get(i).getPin() %>" size="5" class="tdinput" /></td>
                    <td align="left" valign="top" bgcolor="#cccccc">
                    <input name="contEmail1" id="contEmail1" type="text" value="<%=aclist.get(i).getEmail() %>" size=5 class="tdinput" /></td>
                    <td align="left" valign="top" bgcolor="#cccccc">
                    <input name="contPhone1" id="contPhone1" type="text" value="<%=aclist.get(i).getPhone() %>" size=5 class="tdinput" /></td>
                    <td align="left" valign="top" bgcolor="#cccccc">
                    <input name="contJobRole1" id="contJobRole1" type="text" value="<%=aclist.get(i).getJobRole() %>" size=5 class="tdinput" /></td>
                    <td align="left" valign="top" bgcolor="#cccccc">
                    <input name="lstCont1" id="lstCont1" type="text" value="<%=lcdate %>" size=5 class="tdinput" /></td>
                 </tr>
                 <%
                  	}
                  	
                  }
                 %>
                
                </table></td>
              </tr>
              <tr>
              <td><a href="javascript: addRow('iTable')" style="font-size:24px; font-weight:bold" title="Add Row">+</a>
              <a href="javascript: deleteRow('iTable')"  style="font-size:24px; font-weight:bold" title="Delete Row">-</a>
              </td>
              </tr>
              </table>
              </td>
              </tr>
              <tr>
                <td height="5"></td>
              </tr>
            </table>                       </td>
 		 </tr>
          
          <tr>
            <td align="left" valign="top">
            <a href="<%=application.getContextPath() %>/accountsInAdmin/open.do"><input type="button" class="button-black-right"  value="Clear"/></a>
            <input type="button" class="button-black-right"  value="Edit" onclick="javascript: retriveClient()"/>
            <input type="submit" class="button-black-right" value="Submit" />   
           <input type="hidden" name="rCount" id="rCount" value="1"/>
             </td>
          </tr>
          <tr>
            <td height="10">&nbsp;</td>
                     
          </tr>
          <tr>
            <td align="right" valign="top">&nbsp;</td>
          </tr>
          
          <tr>
            <td align="left" valign="top">&nbsp;</td>
          </tr>
        </table></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      
    </table></td>
  </tr>
  <tr>
    <td height="40" align="left" valign="top" bgcolor="#0B0B0B">&nbsp;</td>
  </tr>
</table>
</form>
<div id="bulletinDialog" style="display: none;">
                  <div id="clientSearchBox">
           <form action="<%= application.getContextPath()%>/accountsInAdmin/clientEdit.do" method="post">
           			<br />      
                    <select name="clientName" class="form" id="clientId">
               			 <option value="Please Select">Please Select</option>
                   </select>
                   <input type="hidden" id="exName" name="exeName"/>
                   <br />
                   <br />
                    <input class="button-right" type="submit" id="ok" value="OK"/> 
                    </form>
                    </div>
                    
        </div>
</body>
</html>
<%-- <script>
$(document).ready(function(){
	$("#go").click(function(){
		var org=$("#org").val();
		window.location="<%=application.getContextPath() %>/accounts/getAcc.do?orgn="+org;
	});
});
</script> --%>
<script  type="text/javascript">
function retriveClient(){
	var exeName=$("#exeName").val();
	var data="exeName="+exeName;
	$("#exName").val(exeName);
	$.ajax({
		url:" <%=application.getContextPath()%>/accountsInAdmin/getClientDet.do",
		mimetype: "text/plain",
		cache:false,
		data: data,
		success: function(res){
			var e2=document.getElementById('clientId');
			$('#clientId')
		    .find('option')
		    .remove()
		    .end()
		   	;
			var temp=res.split(",");
			var o=document.createElement('option');
			o.value="Please Select";
			o.text="Please Select";
			e2.options.add(o);
			if(temp != null){
				for(var i=0;i<temp.length-1;i++){
					var o=document.createElement('option');
					o.value=temp[i];
					o.text=temp[i];
					e2.options.add(o);
				}
			}
			//$("#clientSearchBox").html(res);
			
		}

	});

var $dialog = $('#bulletinDialog').dialog({
                autoOpen: false,
                modal: true,
                width: 250,
                height: 120,
              				
            });
 			 
            $dialog.dialog('open');
}
</script>